<%@ page import="ro.gateway.aida.sectors.SectorWrapper"%>
<%@ taglib uri="/WEB-INF/translator.tld" prefix="trans" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<trans:initPage module="viewsectors" />
<script language="javascript">
function sopenw(targetwindow, url, width, height) {
      var args = "HEIGHT=" + height + ",WIDTH=" + width +
            ",SCROLLBARS=YES,LEFT=" +
            (window.screen.availWidth - width) / 2 +
            ",TOP=" +
            (window.screen.availHeight - height) / 2;
      window.open(url, targetwindow, args);
};
function refresh_() {
     window.location.reload();
}
</script>
<logic:notPresent name="sectors">
      <trans:showPageMessage label="viewsectors.nosectorsavailable" />
</logic:notPresent>

<logic:present name="sectors">
<%
      SectorWrapper[] sectors = ( SectorWrapper[] ) request.getAttribute("sectors");
      int len = sectors.length;
      boolean first_col = true;
%>
<center>
<table width="100%" border="0">
<tr><td bgcolor="#EEEEEE" valign="top" width="50%" style="font-size:10px;background-color=#EEEEEE;margin-right:5px;padding:5px;">
<logic:iterate id="sector" name="sectors" type="ro.gateway.aida.sectors.SectorWrapper" indexId="i" >
      <% int level = sector.getSector().getLevel(); %>
      <% if (first_col && i.intValue() > (len/2) && sector.getSector().getParent()==null) { first_col = false; %>
      </td>
      <td bgcolor="#EEEEEE" valign="top" style="font-size:10px;background-color=#EEEEEE;margin-right:5px;padding:5px;">
      <% } %>
      <div style="float:right;">
            <% if (level < 2) { %>
            <a class="text_search" href="javascript:sopenw('edit', '<html:rewrite page="/sectors/editor.do?start=true&action=new" />&parent_id=<%=sector.getRo_aida_code()%>',500 ,300);">[ADD]</a>
            <% } %>
            <a class="text_search" href="javascript:sopenw('edit', '<html:rewrite page="/sectors/editor.do?start=true&action=edit" />&id=<%=sector.getRo_aida_code()%>',500 ,300);">[E]</a>
            <a class="text_search" href="javascript:sopenw('edit', '<html:rewrite page="/sectors/editor.do?start=true&action=delete" />&id=<%=sector.getRo_aida_code()%>',500 ,300);">[X]</a>
      </div>
      <% if (sector.getSector().getParent() == null) { %>
      <b><bean:write name="sector" property="title" /></b>
      <% } else { %>
            <% for (int j = 0; j < level; j++) { %>&nbsp;&nbsp;&nbsp;<% } %>
            <bean:write name="sector" property="title" />
      <% } %>
      <div style="clear:both;"></div>
</logic:iterate>
</td></tr>
</table>
</center>
</logic:present>
<div style="clear:both;"></div>
<br>
<a class="text_search" href="javascript:sopenw('edit', '<html:rewrite page="/sectors/editor.do?start=true&action=new" />',500 ,300);">[<trans:showPageMessage label="viewsectors.addmainsector" />]</a>
<br><br>

